<h1>Docker inspect 命令</h1>
<p><strong>docker inspect :</strong> 获取容器/镜像的元数据。</p>
<h3>语法</h3>
<pre><code class="language-Docker">docker inspect [OPTIONS] NAME|ID [NAME|ID...]</code></pre>
<p>OPTIONS说明：</p>
<ul>
<li><p><strong>-f :</strong>指定返回值的模板文件。</p></li>
<li><p><strong>-s :</strong>显示总的文件大小。</p></li>
<li><p><strong>--type :</strong>为指定类型返回JSON。</p></li>
</ul>
<h3>实例</h3>
<p>获取镜像mysql:5.6的元信息。</p>
<pre><code class="language-Docker">runoob@runoob:~$ docker inspect mysql:5.6

[

    {

        "Id": "sha256:2c0964ec182ae9a045f866bbc2553087f6e42bfc16074a74fb820af235f070ec",

        "RepoTags": [

            "mysql:5.6"

        ],

        "RepoDigests": [],

        "Parent": "",

        "Comment": "",

        "Created": "2016-05-24T04:01:41.168371815Z",

        "Container": "e0924bc460ff97787f34610115e9363e6363b30b8efa406e28eb495ab199ca54",

        "ContainerConfig": {

            "Hostname": "b0cf605c7757",

            "Domainname": "",
            "User": "",

            "AttachStdin": false,

            "AttachStdout": false,

            "AttachStderr": false,

            "ExposedPorts": {

                "3306/tcp": {}

            },

...

</code></pre>
<p>获取正在运行的容器mymysql的 IP。 </p>
<pre><code class="language-Docker">runoob@runoob:~$ docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' mymysql

172.17.0.3

</code></pre>

